/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cjava.system.util.convert;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.FacesConverter;
import org.cjava.system.model.Teacher;
import org.omnifaces.converter.SelectItemsConverter;

/**
 *
 * @author max
 */
@FacesConverter("teacherconvert")
public class TeacherConverter extends SelectItemsConverter{
    
    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        Integer id = (value instanceof Teacher) ? ((Teacher) value).getId() : null;
        return (id != null) ? String.valueOf(id) : null;
    }
    
}
